{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "Java 数据类型：\n",
    "\n",
    "* 原生数据类型：```byte, short, int, float, double, boolean, char```\n",
    "* 引用数据类型：```Byte, Short, Integer, Float, Double, Boolean, String```\n",
    "\n",
    "Python 数据类型：\n",
    "\n",
    "* 原生数据类型：数字、字符串、布尔\n",
    "* 引用类型：```list, tuple, set, dict```"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10 <class 'int'>\n",
      "10.23 <class 'float'>\n",
      "Hello, World <class 'str'>\n",
      "True <class 'bool'>\n",
      "False <class 'bool'>\n"
     ]
    }
   ],
   "source": [
    "a = 10\n",
    "print(a, type(a))\n",
    "a = 10.23\n",
    "print(a, type(a))\n",
    "a = 'Hello, World'\n",
    "print(a, type(a))\n",
    "a = True\n",
    "print(a, type(a))\n",
    "a = False\n",
    "print(a, type(a))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4, 5] <class 'list'>\n",
      "(1, 2, 3, 4, 5) <class 'tuple'>\n",
      "{1, 2, 3, 4, 5} <class 'set'>\n",
      "{'name': 'Jerry', 'gender': 'male'} <class 'dict'>\n"
     ]
    }
   ],
   "source": [
    "a = [1, 2, 3, 4, 5]\n",
    "print(a, type(a))\n",
    "a = (1, 2, 3, 4, 5)\n",
    "print(a, type(a))\n",
    "a = {1, 2, 3, 4, 5}\n",
    "print(a, type(a))\n",
    "a = {\n",
    "    'name': 'Jerry',\n",
    "    'gender': 'male'\n",
    "}\n",
    "print(a, type(a))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "比较操作符：\n",
    "```\n",
    ">\n",
    ">=\n",
    "==\n",
    "<\n",
    "<=\n",
    "!\n",
    "in\n",
    "not in\n",
    "```\n",
    "\n",
    "逻辑操作符：\n",
    "```\n",
    "and\n",
    "or\n",
    "not\n",
    "```"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "False\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "a = 10\n",
    "b = 10\n",
    "print(a == b)\n",
    "print(a in [20, 30])\n",
    "print(a not in [20, 30])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "不可以参军\n"
     ]
    }
   ],
   "source": [
    "age = 18\n",
    "gender = \"female\"\n",
    "\n",
    "if age >= 18 and gender == \"male\":\n",
    "    print(\"可以参军\")\n",
    "else:\n",
    "    print(\"不可以参军\")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "finished\n"
     ]
    }
   ],
   "source": [
    "for x in range(5):\n",
    "    print(x)\n",
    "else:\n",
    "    print(\"finished\")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "3\n",
      "5\n",
      "7\n",
      "9\n",
      "finished\n"
     ]
    }
   ],
   "source": [
    "for x in range(1, 10, 2):\n",
    "    print(x)\n",
    "else:\n",
    "    print(\"finished\")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "100\n",
      "17\n",
      "finished\n"
     ]
    }
   ],
   "source": [
    "lst = [1, 100, 17]\n",
    "for x in lst:\n",
    "    print(x)\n",
    "else:\n",
    "    print(\"finished\")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "3\n",
      "5\n",
      "7\n",
      "9\n",
      "finished\n"
     ]
    }
   ],
   "source": [
    "n = 1\n",
    "while n < 10:\n",
    "    print(n)\n",
    "    n += 2\n",
    "else:\n",
    "    print(\"finished\")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 3, 5]\n",
      "[1, 5]\n",
      "[1, 2]\n",
      "1\n",
      "1\n"
     ]
    }
   ],
   "source": [
    "a = []\n",
    "a.append(1)\n",
    "a.append(3)\n",
    "a.append(5)\n",
    "print(a)\n",
    "a.remove(3)\n",
    "print(a)\n",
    "a[1] = 2\n",
    "print(a)\n",
    "print(a.count(2))\n",
    "print(a.index(2))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[17, 12, 1, 5, 7]\n",
      "[7, 5, 1, 12, 17]\n",
      "[1, 5, 7, 12, 17]\n",
      "[17, 12, 7, 5, 1]\n"
     ]
    }
   ],
   "source": [
    "a = [17, 12, 1, 5, 7]\n",
    "print(a)\n",
    "a.reverse()\n",
    "print(a)\n",
    "a.sort()\n",
    "print(a)\n",
    "a.reverse()\n",
    "print(a)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "outputs": [],
   "source": [
    "import random"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.1748176474778741\n"
     ]
    }
   ],
   "source": [
    "print(random.random())"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "43\n"
     ]
    }
   ],
   "source": [
    "print(random.randint(25, 100))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "outputs": [
    {
     "data": {
      "text/plain": "[27,\n 36,\n 52,\n 66,\n 41,\n 31,\n 77,\n 37,\n 99,\n 65,\n 93,\n 32,\n 66,\n 100,\n 89,\n 39,\n 27,\n 29,\n 65,\n 95,\n 84,\n 65,\n 55,\n 34,\n 62,\n 80,\n 36,\n 56,\n 61,\n 45,\n 79,\n 48,\n 89,\n 78,\n 81,\n 61,\n 49,\n 57,\n 37,\n 70,\n 42,\n 53,\n 65,\n 25,\n 84,\n 47,\n 37,\n 93,\n 26,\n 73]"
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[random.randint(25, 100) for x in range(50)]"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53]\n"
     ]
    }
   ],
   "source": [
    "a = list(range(54))\n",
    "print(a)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[23, 25, 13, 38, 44, 6, 4, 1, 2, 12, 34, 46, 0, 17, 19, 18, 31, 36, 51, 29, 8, 30, 9, 39, 50, 52, 41, 10, 24, 45, 43, 48, 26, 37, 21, 28, 3, 49, 5, 14, 33, 42, 53, 47, 16, 15, 22, 7, 32, 35, 40, 20, 11, 27]\n"
     ]
    }
   ],
   "source": [
    "random.shuffle(a)\n",
    "print(a)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}